/* GUI CONVERTED from icptiq02.p (converter v1.76) Tue Apr  9 21:12:30 2002 */
/* icptiq02.p - ALLOCATION INQUIRY                                      */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.15 $                                                         */
/*V8:ConvertMode=Report                                        */
/* REVISION: 6.0     LAST EDIT: 05/10/90    BY: pml            */
/* REVISION: 6.0      LAST MODIFIED: 08/02/91   BY: bjb *D894**/
/* REVISION: 6.0      LAST MODIFIED: 10/03/91   BY: alb *D887**/
/* REVISION: 7.0      LAST MODIFIED: 05/14/92   BY: tjs *F491**/
/* REVISION: 7.0      LAST MODIFIED: 05/15/92   BY: emb *F505**/
/* REVISION: 7.0      LAST MODIFIED: 07/09/92   BY: pma *F751**/
/* REVISION: 7.0      LAST MODIFIED: 07/30/92   BY: emb *F822**/
/* REVISION: 7.3      LAST MODIFIED: 02/08/93   BY: emb *G656**/
/* REVISION: 7.3      LAST MODIFIED: 05/15/93   BY: emb *GA99**/
/* REVISION: 7.3      LAST MODIFIED: 10/01/93   BY: pxd *GG11**/
/* REVISION: 7.3      LAST MODIFIED: 11/24/93   BY: ais *GH62**/
/* REVISION: 7.3      LAST MODIFIED: 01/26/94   BY: ais *FL58**/
/* REVISION: 8.5      LAST MODIFIED: 10/25/94   BY: TAF *J038**/
/* REVISION: 8.5      LAST MODIFIED: 10/28/94   BY: qzl *FT04**/
/* REVISION: 8.5      LAST MODIFIED: 08/24/95   BY: qzl *F0TV**/
/* REVISION: 8.5      LAST MODIFIED: 04/11/96   BY: *J04C* Sue Poland   */
/* REVISION: 8.5      LAST MODIFIED: 06/11/96   BY: *J0S5* Rob Wachowicz */
/* REVISION: 8.5      LAST MODIFIED: 06/28/96   BY: *J0WM* Rob Wachowicz */
/* REVISION: 8.6      LAST MODIFIED: 09/27/96   BY: *K003* forrest mori  */
/* REVISION: 8.6      LAST MODIFIED: 01/16/97   BY: *J1DL* Murli Shastri */
/* REVISION: 8.6      LAST MODIFIED: 04/11/97   BY: *J1KC* Russ Witt     */
/* REVISION: 8.6      LAST MODIFIED: 10/22/97   BY: ays *K14G*           */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane     */
/* REVISION: 8.6E     LAST MODIFIED: 06/09/98   BY: *K1RK* Mohan CK      */
/* REVISION: 9.1      LAST MODIFIED: 08/23/99   BY: *N01V* Jyoti Thatte  */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 07/18/00   BY: *N0GB* Mudit Mehta      */
/* REVISION: 9.1      LAST MODIFIED: 08/23/00   BY: *N0ND* Mark Brown       */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.15 $    BY: Anitha Gopal          DATE: 04/01/02  ECO: *N1FT*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE icptiq02_p_2 "Picked"
/* MaxLen: Comment: */

&SCOPED-DEFINE icptiq02_p_3 "Unallocated"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable part like pt_part.
define variable site like pt_site.
define variable loc like ld_loc.
define variable lot like ld_lot.
define variable stat like ld_status.
define variable type like sod_type format "X(2)".
define variable gen_all like lad_qty_all.
define variable tot_all like lad_qty_all.
define variable gen_pick like lad_qty_pick.
define variable tot_pick like lad_qty_pick.
define variable qty_unall like in_qty_all column-label {&icptiq02_p_3}.
define variable first_time  as logical.
define variable first_ladln as logical.

/* SELECT FORM */
assign
   part = global_part
   site = global_site.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/  part site loc lot stat
with frame a no-underline width 80 THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* REPORT BLOCK */

{wbrp01.i}
repeat:

   if c-application-mode <> 'web'
   then
      update part site loc lot stat with frame a
   editing:

      if frame-field = "part"
      then do:
         /* FIND NEXT/PREVIOUS RECORD */
         {mfnp.i pt_mstr part pt_part part pt_part pt_part}
         if recno <> ?
         then do:
            part = pt_part.
            display part  with frame a.
         end. /* IF recno <> ? */
      end. /* IF frame-field = "part" */
      else do:
         status input.
         readkey.
         apply lastkey.
      end. /* ELSE DO */
   end. /* EDITING */

   {wbrp06.i &command = update &fields = "  part site loc lot stat" &frm = "a"}

   if (c-application-mode <> 'web')
      or  (c-application-mode = 'web'
      and (c-web-request begins 'data'))
   then do:

      hide frame b1.
      hide frame c.

   end. /* IF (c-application-mode <> 'web') */
   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}

   /* FIND AND DISPLAY */
   loop-inmstr:
   for each in_mstr no-lock
      where in_part = part
      and  (in_site = site
            or site = "")
      by in_part with frame b1 no-underline width 80
      title color normal (getFrameTitle("SITE_SUMMARY",16)):

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b1:handle).

      if loc     <> ""
         or lot  <> ""
         or stat <> ""
      then do:
         find first ld_det no-lock
            where ld_part = in_part
            and   ld_site = in_site
            and   (ld_loc = loc
                  or loc  = "")
            and   (ld_lot = lot
                  or lot  = "")
            and   (ld_status = stat
                  or stat = "")
            no-error.
         if not available ld_det
         then
            next.
      end. /* IF loc <> "" */

      find pt_mstr
         where pt_part = in_part no-lock.

      display
         pt_desc1
         in_site
         in_qty_avail
         pt_um
         in_qty_all
         max(in_qty_avail - in_qty_all,0) @ qty_unall 
         WITH STREAM-IO /*GUI*/ .

      assign
         tot_all  = 0
         tot_pick = 0.

      do with frame c down width 80:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame c:handle).

         run so-alloc-iq
            (input in_part,
            input in_site).

         
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         /* SALES ORDER BILL ALLOCATIONS FOR KIT COMPONENTS */
         sobdet:
         do with frame c:

            for each lad_det no-lock
               where lad_dataset = "sob_det"
               and   lad_site = in_site
               and   lad_part = in_part
               and   (lad_loc = loc
                     or loc   = "")
               and   (lad_lot = lot
                     or lot   = "")
               with frame c break
               by lad_dataset
               by lad_nbr
               by lad_line
               by lad_part
               by lad_loc
               by lad_lot
               by lad_ref:

               /* THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR
               THE STATUS ENTERED BY THE USER. */
               if first-of(lad_nbr)
               then
                  first_time  = yes.
               if first-of(lad_line)
               then
                  first_ladln = yes.
               if stat <> ""
                  and not can-find(first ld_det
                                   where ld_status = stat
                  and   ld_part = lad_part
                  and   ld_site = lad_site
                  and   ld_loc  = lad_loc
                  and   ld_lot  = lad_lot
                  use-index ld_status)
               then
                  next.
               if line-counter > 1
                  or frame-line <> 0
               then
                  down 1 with frame c.

               if first_time
               then
                  display
                     substring(lad_dataset,1,2) @ type
                     lad_nbr
                     lad_line
                  with frame c STREAM-IO /*GUI*/ .

               if first_ladln
               then
                  display
                     lad_line
                  with frame c STREAM-IO /*GUI*/ .

               assign
                  first_time  = no
                  first_ladln = no.

               display
                  lad_loc lad_lot
                  lad_qty_all format "->>>>>9.9<<<<<"
                  lad_qty_pick format "->>>>>9.9<<<<<"
                  column-label {&icptiq02_p_2}
               with frame c STREAM-IO /*GUI*/ .

               if lad_ref <> ""
               then do with frame c:
                  down 1 with frame c.

                  display getTermLabelRtColon("REFERENCE",7) +
                     " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .
               end. /* IF lad_ref <> "" */

               assign
                  tot_all = tot_all + lad_qty_all
                  tot_pick = tot_pick + lad_qty_pick.

               
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


            end. /* FOR EACH lad_det */

            
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         end. /* DO WITH FRAME C */

         /* ALLOCATIONS FOR WORK ORDERS*/
         run alloc-wo
            (input in_part,
            input in_site).

         
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/
/*** hwird_det begin** zy  **/

             /* ALLOCATIONS FOR REPETITIVE PICKLISTS */
         gen_all = 0.
         for each lad_det no-lock
            where lad_dataset = "hwird_det"
            and   lad_part = in_part
            and   lad_site = in_site
            and   (lad_loc = loc
                  or loc   = "")
            and   (lad_lot = lot
                  or lot   = "")
            with frame c
            break by lad_dataset
                  by lad_nbr
                  by lad_line
                  by lad_part
                  by lad_loc
                  by lad_lot
                  by lad_ref:

            /*  THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR
            THE STATUS ENTERED BY THE USER. */
/*             if stat <> ""                                 */
/*                and not can-find(first ld_det              */
/*                                    where ld_status = stat */
/*                and   ld_part = lad_part                   */
/*                and   ld_site = lad_site                   */
/*                and   ld_loc  = lad_loc                    */
/*                and   ld_lot  = lad_lot                    */
/*                use-index ld_status)                       */
/*             then                                          */
/*                next.                                      */
             FIND wo_mstr NO-LOCK WHERE wo_lot =lad_nbr NO-ERROR.

            assign
               tot_all = tot_all + lad_qty_all
               tot_pick = tot_pick + lad_qty_pick.

            if line-counter > 1
               or frame-line <> 0
            then
               down 1 with frame c.

            display
               lad_loc
               lad_lot
               (substring(lad_dataset,1,2)) when (first-of
               (lad_nbr)) @ type /* substring(lad_nbr,9,10)*/
                wo_nbr
               when (first-of(lad_nbr)) @ lad_nbr
               lad_line when (first-of(lad_nbr))
               lad_qty_all
               lad_qty_pick
            with frame c STREAM-IO /*GUI*/ .

            if lad_ref <> ""
            then do with frame c:
               down 1 with frame c.

               display getTermLabelRtColon("REFERENCE",7) +
                  " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .

            end. /* IF lad_ref <> "" */

            
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         end. /*  FOR EACH lad_det no-lock */

         
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


/** hwird_det  end***/


/*** hiud_det begin** zy  **/

             /* ALLOCATIONS FOR REPETITIVE PICKLISTS */
         gen_all = 0.
         for each lad_det no-lock
            where lad_dataset = "hiud_det"
            and   lad_part = in_part
            and   lad_site = in_site
            and   (lad_loc = loc
                  or loc   = "")
            and   (lad_lot = lot
                  or lot   = "")
            with frame c
            break by lad_dataset
                  by lad_nbr
                  by lad_line
                  by lad_part
                  by lad_loc
                  by lad_lot
                  by lad_ref:

            /*  THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR
            THE STATUS ENTERED BY THE USER. */
/*             if stat <> ""                                 */
/*                and not can-find(first ld_det              */
/*                                    where ld_status = stat */
/*                and   ld_part = lad_part                   */
/*                and   ld_site = lad_site                   */
/*                and   ld_loc  = lad_loc                    */
/*                and   ld_lot  = lad_lot                    */
/*                use-index ld_status)                       */
/*             then                                          */
/*                next.                                      */

            assign
               tot_all = tot_all + lad_qty_all
               tot_pick = tot_pick + lad_qty_pick.

            if line-counter > 1
               or frame-line <> 0
            then
               down 1 with frame c.

            display
               lad_loc
               lad_lot
               (substring(lad_dataset,1,2)) when (first-of
               (lad_nbr)) @ type /* substring(lad_nbr,9,10)*/
                lad_nbr
               when (first-of(lad_nbr)) @ lad_nbr
               lad_line when (first-of(lad_nbr))
               lad_qty_all
               lad_qty_pick
            with frame c STREAM-IO /*GUI*/ .

            if lad_ref <> ""
            then do with frame c:
               down 1 with frame c.

               display getTermLabelRtColon("REFERENCE",7) +
                  " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .

            end. /* IF lad_ref <> "" */

            
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         end. /*  FOR EACH lad_det no-lock */

         
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


/** hiud_det  end***/



         /* ALLOCATIONS FOR REPETITIVE PICKLISTS */
         gen_all = 0.
         for each lad_det no-lock
            where lad_dataset = "rps_det"
            and   lad_part = in_part
            and   lad_site = in_site
            and   (lad_loc = loc
                  or loc   = "")
            and   (lad_lot = lot
                  or lot   = "")
            with frame c
            break by lad_dataset
                  by lad_nbr
                  by lad_line
                  by lad_part
                  by lad_loc
                  by lad_lot
                  by lad_ref:

            /*  THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR
            THE STATUS ENTERED BY THE USER. */
            if stat <> ""
               and not can-find(first ld_det
                                   where ld_status = stat
               and   ld_part = lad_part
               and   ld_site = lad_site
               and   ld_loc  = lad_loc
               and   ld_lot  = lad_lot
               use-index ld_status)
            then
               next.

            assign
               tot_all = tot_all + lad_qty_all
               tot_pick = tot_pick + lad_qty_pick.

            if line-counter > 1
               or frame-line <> 0
            then
               down 1 with frame c.

            display
               lad_loc
               lad_lot
               (substring(lad_dataset,1,2)) when (first-of
               (lad_nbr)) @ type substring(lad_nbr,9,10)
               when (first-of(lad_nbr)) @ lad_nbr
               lad_line when (first-of(lad_nbr))
               lad_qty_all
               lad_qty_pick
            with frame c STREAM-IO /*GUI*/ .

            if lad_ref <> ""
            then do with frame c:
               down 1 with frame c.

               display getTermLabelRtColon("REFERENCE",7) +
                  " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .

            end. /* IF lad_ref <> "" */

            
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         end. /*  FOR EACH lad_det no-lock */

         
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         /* ALLOCATIONS FOR INTERSITE DEMANDS */
         for each ds_det no-lock
            where ds_part     = in_part
            and   ds_shipsite = in_site
            and   (ds_qty_all <> 0
                  or ds_qty_pick <> 0)
            with frame c:

            /* CHECK FOR DETAIL ALLOCATIONS */
            assign
               gen_all  = ds_qty_all + ds_qty_pick
               tot_all  = tot_all + ds_qty_all
               tot_pick = tot_pick + ds_qty_pick.

            for each lad_det no-lock
               where lad_dataset = "ds_det"
               and   lad_nbr     = ds_req_nbr
               and   lad_line    = ds_site
               and   lad_part    = ds_part
               with frame c break
               by lad_dataset
               by lad_nbr
               by lad_line
               by lad_part
               by lad_loc
               by lad_lot
               by lad_ref:

               gen_all = gen_all - lad_qty_all - lad_qty_pick.

               /*  THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR */
               /* THE STATUS ENTERED BY THE USER. */
               if first-of(lad_nbr)
               then
                  first_time = yes.
               if stat <> ""
                  and not can-find(first ld_det
                                      where ld_status = stat
                  and ld_part = lad_part
                  and ld_site = lad_site
                  and ld_loc  = lad_loc
                  and ld_lot  = lad_lot
                  use-index ld_status)
               then
                  next.

               if (lad_site   <> site
                   and site   <> "")
                  or (lad_loc <>  loc
                   and  loc   <> "")
                  or (lad_lot <>  lot
                   and  lot   <> "")
               then do:
                  assign
                     tot_all = tot_all - lad_qty_all
                     tot_pick = tot_pick - lad_qty_pick.
                  next.
               end. /* IF (lad_site   <> site */

               if line-counter > 1
                  or frame-line <> 0
               then
                  down 1 with frame c.

               if first_time
               then
                  display
                     (substring(lad_dataset,1,2)) @ type
                     lad_nbr
                     lad_line
                  with frame c STREAM-IO /*GUI*/ .
               first_time = no.

               display
                  lad_loc
                  lad_lot
                  lad_qty_all
                  lad_qty_pick
               with frame c STREAM-IO /*GUI*/ .

               if lad_ref <> ""
               then do with frame c:
                  down 1 with frame c.

                  display
                     getTermLabelRtColon("REFERENCE",7) +
                     " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .

               end. /* IF lad_ref <> "" */

               
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


            end. /* FOR EACH lad_det no-lock */

            
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


            if gen_all <> 0
               and (loc     <> ""
                    or lot  <> ""
                    or stat <> "")
            then
               tot_all = tot_all - gen_all.

            if gen_all  <> 0
               and loc  = ""
               and lot  = ""
               and stat = ""
            then do with frame c:
               if line-counter > 1
                  or frame-line <> 0
               then
                  down 1 with frame c.

               display
                  (substring("ds_det",1,2)) @ type
                  ds_req_nbr @ lad_nbr
                  ds_site @ lad_line
                  gen_all @ lad_qty_all
               with frame c STREAM-IO /*GUI*/ .

            end. /* IF gen_all <> 0 */

            
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         end. /* FOR EACH ds_det no-lock */

         
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         /* DISPLAY ALLOCATIONS FOR SERVICE CALLS */
         gen_all = 0.
         for each lad_det no-lock
            where lad_dataset = "itm_det"
            and   lad_part = in_part
            and   lad_site = in_site
            and   (lad_loc = loc
                   or loc = "")
            and   (lad_lot = lot
                   or lot = "")
            with frame c
            break by lad_dataset
                  by lad_nbr
                  by lad_line
                  by lad_part
                  by lad_loc
                  by lad_lot
                  by lad_ref:

            /* THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR */
            /* THE STATUS ENTERED BY THE USER. */
            if  stat <> ""
               and not can-find(first ld_det
                                   where ld_status = stat
               and   ld_part = lad_part
               and   ld_site = lad_site
               and   ld_loc  = lad_loc
               and   ld_lot  = lad_lot
               use-index ld_status)
            then
               next.

            assign
               tot_all = tot_all + lad_qty_all
               tot_pick = tot_pick + lad_qty_pick.

            if line-counter > 1
               or frame-line <> 0
            then
               down 1 with frame c.

            display
               lad_loc
               lad_lot
               (substring("CALL",1,2)) @ type
               lad_nbr
               lad_line
               lad_qty_all
               lad_qty_pick
            with frame c STREAM-IO /*GUI*/ .

            if lad_ref <> ""
            then do with frame c:
               down 1 with frame c.
               display
                  getTermLabelRtColon("REFERENCE",7) +
                  " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .
            end. /* IF lad_ref <> "" */

            
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         end. /* FOR EACH lad_det no-lock */

         
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=false} /*Replace mfrpchk*/


         if line-counter > 1
            or frame-line <> 0
         then
            down 1 with frame c.

         if (line-counter > 1
            and page-size - line-counter < 2)
            or (frame-line <> 0
               and frame-down - frame-line < 1)
         then
            down 1 with frame c.

         underline
            lad_qty_all
            lad_qty_pick.
         display
            tot_all @ lad_qty_all
            tot_pick @ lad_qty_pick WITH STREAM-IO /*GUI*/ .

      end. /* DO WITH FRAME C DOWN WIDTH 80 */

      
/*GUI*/ {mfguichk.i  &label=loop-inmstr &warn=true} /*Replace mfrpchk*/


   end. /* FOR EACH in_mstr NO-LOCK */

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}
end. /* REPEAT */

global_part = part.
global_site = site.

{wbrp04.i &frame-spec = a}

PROCEDURE so-alloc-iq:

   define input parameter c-in_part like in_part no-undo.
   define input parameter c-in_site like in_site no-undo.

   soddet-loop:
   for each sod_det
      where sod_part = c-in_part
      and   sod_site = c-in_site
      and   (sod_qty_all <> 0
            or sod_qty_pick <> 0)
      and   sod_confirm and sod_type = ""
      no-lock with frame c:

      /* ALLOCATIONS FOR SALES ORDERS */
      assign
         gen_all = 0
         gen_pick = 0.
      if loc = ""
         and lot = ""
      then
         assign
            gen_all = (sod_qty_all + sod_qty_pick) * sod_um_conv
            tot_all = tot_all + sod_qty_all * sod_um_conv
            gen_pick = sod_qty_pick * sod_um_conv.

      if loc      = ""
         and lot  = ""
         and stat <> ""
      then
         tot_all = tot_all - sod_qty_all * sod_um_conv.

      for each lad_det no-lock
         where lad_dataset = "sod_det"
         and   lad_nbr = sod_nbr
         and   (lad_loc = loc
               or loc = "")
         and   (lad_lot = lot
               or lot = "")
         and   (lad_site = site
               or site = "")
         and   lad_line = string(sod_line)
         with frame c break
            by lad_dataset
            by lad_nbr by lad_line
            by lad_part
            by lad_loc by lad_lot by lad_ref:

         /*  THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR
         THE STATUS ENTERED BY THE USER. */
         if first-of(lad_nbr) then first_time = yes.
         if  stat <> ""
            and not can-find(first ld_det where ld_status = stat
            and   ld_part = lad_part
            and   ld_site = lad_site
            and   ld_loc  = lad_loc
            and   ld_lot  = lad_lot
            use-index ld_status) then
            next.

         if loc = "" and lot = ""
            then
         assign
            gen_all = gen_all - lad_qty_all - lad_qty_pick
            tot_pick = tot_pick + lad_qty_pick
            gen_pick = gen_pick - lad_qty_pick.
         else
         assign
            gen_all = lad_qty_all
            tot_pick = tot_pick + lad_qty_pick
            gen_pick = lad_qty_pick.

         if line-counter > 1 or frame-line <> 0
            then down 1 with frame c.

         /* START OF ADDED SECTION */

         if first_time then
         display substring(lad_dataset,1,2) @ type
            lad_nbr lad_line with frame c STREAM-IO /*GUI*/ .
         first_time = no.
         display
            lad_loc lad_lot
            lad_qty_all format "->>>>>9.9<<<<<"
            lad_qty_pick format "->>>>>9.9<<<<<"
            column-label {&icptiq02_p_2}
         with frame c STREAM-IO /*GUI*/ .

         if lad_ref <> ""
         then do with frame c:
            down 1 with frame c.

            display getTermLabelRtColon("REFERENCE",7) +
               " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .
         end. /* IF lad_ref <> "" */
         if loc <> "" or lot <> ""
         then
            gen_all = 0.

         if loc <> ""
            or lot <> ""
            or stat <> ""
         then
            tot_all = tot_all + lad_qty_all.

         
/*GUI*/ {mfguichk.i  &loop=soddet-loop &warn=false} /*Replace mfrpchk*/


      end. /* FOR EACH lad_det no-lock */

      
/*GUI*/ {mfguichk.i  &loop=soddet-loop &warn=true} /*Replace mfrpchk*/


      if gen_all <> 0 and (sod_loc = loc or loc = "")
         and (sod_lot = lot or lot = "")
         and stat = ""
         then do with frame c:
         tot_pick = tot_pick + gen_pick.
         if line-counter > 1
            or frame-line <> 0
         then down 1 with frame c.
         display
            (substring("sod_det",1,2)) @ type
            sod_nbr @ lad_nbr
            string(sod_line) @ lad_line
            gen_all @ lad_qty_all
         with frame c STREAM-IO /*GUI*/ .
      end. /* IF gen_all <> 0 AND (sod_loc = loc OR loc = "") */

      
/*GUI*/ {mfguichk.i  &loop=soddet-loop &warn=true} /*Replace mfrpchk*/


   end. /* FOR EACH sod_det */
END PROCEDURE.

PROCEDURE alloc-wo:

   define input parameter c-in_part like in_part no-undo.
   define input parameter c-in_site like in_site no-undo.

   /* ALLOCATIONS FOR WORK ORDERS*/
   woddet-loop:
   for each wod_det
      where wod_part = c-in_part
      and   wod_site = c-in_site
      and   (wod_qty_all <> 0
            or wod_qty_pick <> 0)
      no-lock with frame c:

      find wo_mstr
         where wo_lot = wod_lot no-lock no-error.
      if wo_type = "S"
      then
         next.

      /*CHECK FOR DETAIL ALLOCATIONS */
      assign
         gen_all = wod_qty_all + wod_qty_pick
         tot_all = tot_all + wod_qty_all
         tot_pick = tot_pick + wod_qty_pick.

      for each lad_det no-lock
         where lad_dataset = "wod_det"
         and   lad_nbr     = wod_lot
         and   lad_line    = string(wod_op)
         and   lad_part    = wod_part
         with frame c break
            by lad_dataset
            by lad_nbr
            by lad_line
            by lad_part
            by lad_loc
            by lad_lot
            by lad_ref:

         gen_all = gen_all - lad_qty_all - lad_qty_pick.

         /* THIS CHECK HAS BEEN ADDED TO FILTER THE RECORDS FOR */
         /* THE STATUS ENTERED BY THE USER. */
         if first-of(lad_nbr)
         then
            first_time = yes.
         if stat <> ""
            and not can-find(first ld_det
                                where ld_status = stat
            and   ld_part = lad_part
            and   ld_site = lad_site
            and   ld_loc  = lad_loc
            and   ld_lot  = lad_lot
            use-index ld_status)
         then
            next.

         if (lad_site <> site
             and site <> "")
            or (lad_loc <>  loc
               and  loc <> "")
            or (lad_lot <>  lot
               and  lot <> "")
         then do:
            assign
               tot_all = tot_all - lad_qty_all
               tot_pick = tot_pick - lad_qty_pick.
            next.
         end. /* IF (lad_site <> site */

         if line-counter > 1
            or frame-line <> 0
         then
            down 1 with frame c.
         display
            (substring(lad_dataset,1,2))
            when (first_time) @ type
            wod_nbr when (first_time) @ lad_nbr
            wod_lot when (first_time) @ lad_line
            lad_loc
            lad_lot
            lad_qty_all
            lad_qty_pick
         with frame c STREAM-IO /*GUI*/ .
         first_time = no.

         if lad_ref <> ""
         then do with frame c:
            down 1 with frame c.

            display getTermLabelRtColon("REFERENCE",7) +
               " " + lad_ref @ lad_lot WITH STREAM-IO /*GUI*/ .
         end. /* IF lad_ref <> "" */

         
/*GUI*/ {mfguichk.i  &loop=woddet-loop &warn=false} /*Replace mfrpchk*/


      end. /* FOR EACH lad_det no-lock */

      
/*GUI*/ {mfguichk.i  &loop=woddet-loop &warn=true} /*Replace mfrpchk*/


      if gen_all <> 0
        and (loc     <> ""
             or lot  <> ""
             or stat <> "")
      then
         tot_all = tot_all - gen_all.

      if gen_all <> 0
         and loc  = ""
         and lot  = ""
         and stat = ""
         then do with frame c:
         if line-counter > 1
            or frame-line <> 0
         then
            down 1 with frame c.
         display
            (substring("wod_det",1,2)) @ type
            wod_nbr @ lad_nbr
            wod_lot @ lad_line
            gen_all @ lad_qty_all
         with frame c STREAM-IO /*GUI*/ .
      end. /* IF gen_all <> 0 */

      
/*GUI*/ {mfguichk.i  &loop=woddet-loop &warn=true} /*Replace mfrpchk*/


   end. /* FOR EACH wod_det */
END PROCEDURE.
